﻿
-- ================================================
-- Remarks: Hard delete is required on specific rows
-- so check for delete type
-- ================================================
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO

IF EXISTS (SELECT * FROM sysobjects WHERE type = 'P' AND name = 'Ivy_Sys_SessionLog_DeleteByDate')
	BEGIN
		DROP  Procedure  Ivy_Sys_SessionLog_DeleteByDate
	END
GO

CREATE PROCEDURE [Ivy_Sys_SessionLog_DeleteByDate]
-- =============================================
-- Author:		<Ram pravesh kr>
-- Create date: <06/06/2016>
-- Description:	<Ivy_Sys_SessionLog_DeleteByDate>
-- =============================================
-- Add the parameters for the stored procedure here
(
	@FromDate datetime,
    @ToDate datetime			
) 
AS
BEGIN
	-- SET NOCOUNT ON added to prevent extra result sets from
	-- interfering with SELECT statements.
	SET NOCOUNT ON;
	--SELECT @FromDate=DATEADD(day,DATEDIFF(day,0,@FromDate),0), 
	       --@ToDate=DATEADD(day,DATEDIFF(day,0,@ToDate),0)
	DELETE FROM [Sys_SessionLog]
	WHERE 
	    (
			CONVERT(VARCHAR(50),UserSessionStartTime,103) BETWEEN CONVERT(VARCHAR(50),@FromDate,103) AND CONVERT(VARCHAR(50),@ToDate,103)
		)
	
 END
 GO

